<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>《我的阿勒泰》评论分析小站</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
        <div class="container">
            <a class="navbar-brand" href="#">
                <i class="fas fa-mountain"></i> 《我的阿勒泰》评论分析
            </a>
            <button class="btn btn-outline-light btn-sm" onclick="toggleAdmin()">
                <i class="fas fa-cog"></i> 管理
            </button>
        </div>
    </nav>

    <!-- 主要内容 -->
    <div class="container mt-4">
        <!-- 剧集信息卡片 -->
        <div class="card mb-4">
            <div class="row g-0">
                <div class="col-md-4">
                    <img src="https://via.placeholder.com/300x450/6f4e37/ffffff?text=我的阿勒泰" 
                         class="img-fluid rounded-start" alt="我的阿勒泰海报">
                </div>
                <div class="col-md-8">
                    <div class="card-body">
                        <h5 class="card-title">《我的阿勒泰》</h5>
                        <p class="card-text">改编自李娟同名散文集，讲述在新疆阿勒泰地区的生活故事，展现人与自然的和谐之美。</p>
                        <div class="row">
                            <div class="col-md-6">
                                <p><strong>平均评分：</strong> <span id="avgRating" class="text-warning">--</span>/5</p>
                                <p><strong>总评论数：</strong> <span id="totalComments">--</span></p>
                            </div>
                            <div class="col-md-6">
                                <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#commentModal">
                                    <i class="fas fa-plus"></i> 写短评
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 统计图表 -->
        <div class="row mb-4">
            <div class="col-md-6">
                <div class="card">
                    <div class="card-header">
                        <h6 class="mb-0">评分分布</h6>
                    </div>
                    <div class="card-body">
                        <canvas id="ratingChart" width="400" height="200"></canvas>
                    </div>
                </div>
            </div>
            <div class="col-md-6">
                <div class="card">
                    <div class="card-header">
                        <h6 class="mb-0">关键词云</h6>
                    </div>
                    <div class="card-body">
                        <div id="wordCloud" class="d-flex flex-wrap gap-2"></div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 分类统计 -->
        <div class="card mb-4">
            <div class="card-header">
                <h6 class="mb-0">分类评价统计</h6>
            </div>
            <div class="card-body">
                <div id="categoryStats" class="row"></div>
            </div>
        </div>

        <!-- 评论列表 -->
        <div class="card">
            <div class="card-header d-flex justify-content-between align-items-center">
                <h6 class="mb-0">最新评论</h6>
                <select class="form-select form-select-sm" style="width: auto;" id="categoryFilter">
                    <option value="all">全部</option>
                    <option value="剧情">剧情</option>
                    <option value="人物">人物</option>
                    <option value="情感">情感</option>
                    <option value="画面">画面</option>
                    <option value="音乐">音乐</option>
                </select>
            </div>
            <div class="card-body">
                <div id="commentsList" class="comments-container"></div>
            </div>
        </div>
    </div>

    <!-- 写评论模态框 -->
    <div class="modal fade" id="commentModal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">发表短评</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <form id="commentForm">
                        <div class="mb-3">
                            <label class="form-label">评分</label>
                            <div class="rating-input">
                                <i class="far fa-star" data-rating="1"></i>
                                <i class="far fa-star" data-rating="2"></i>
                                <i class="far fa-star" data-rating="3"></i>
                                <i class="far fa-star" data-rating="4"></i>
                                <i class="far fa-star" data-rating="5"></i>
                            </div>
                            <input type="hidden" id="ratingInput" name="rating" required>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">分类</label>
                            <select class="form-select" name="category">
                                <option value="general">综合</option>
                                <option value="剧情">剧情</option>
                                <option value="人物">人物</option>
                                <option value="情感">情感</option>
                                <option value="画面">画面</option>
                                <option value="音乐">音乐</option>
                            </select>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">评论内容</label>
                            <textarea class="form-control" name="content" rows="3" maxlength="200" 
                                      placeholder="分享你对《我的阿勒泰》的看法..." required></textarea>
                            <small class="form-text text-muted">最多200字</small>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" onclick="submitComment()">提交</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 管理登录模态框 -->
    <div class="modal fade" id="adminModal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">管理员登录</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <form id="adminForm">
                        <div class="mb-3">
                            <label class="form-label">密码</label>
                            <input type="password" class="form-control" id="adminPassword" required>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" onclick="adminLogin()">登录</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 管理面板模态框 -->
    <div class="modal fade" id="adminPanel" tabindex="-1">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">评论管理</h5>
                    <button type="button" class="btn-close" onclick="adminLogout()"></button>
                </div>
                <div class="modal-body">
                    <div id="adminCommentsList" class="list-group"></div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <script src="{{ url_for('static', filename='js/main.js') }}"></script>
</body>
</html>
